var t = getApp(), a = null, e = wx.createInnerAudioContext();

e.src = "/voice/2.mp3", Page({
    data: {
        StatusBar: t.globalData.StatusBar,
        CustomBar: t.globalData.CustomBar,
        status: {
            voice: !0,
            style: 1
        },
        awardsList: [],
        defineCurIndex: 0,
        defineText: [ {
            title: "犯错惩罚",
            text: [ "跪榴莲", "跪搓衣板", "跪键盘", "跪方便面", "跪酒瓶", "跪遥控器", "跪榴莲", "跪搓衣板", "跪键盘", "跪方便面", "跪酒瓶", "跪遥控器" ]
        }, {
            title: "游戏惩罚",
            text: [ "真心话", "唱歌跳舞", "30个俯卧撑", "告白", "表情帝", "撒娇", "喝一杯", "喝半杯", "下家喝", "上家喝", "指定一家喝", "没事" ]
        }, {
            title: "家务活",
            text: [ "买菜", "做饭", "洗碗", "擦地", "洗衣", "呆着", "买菜", "做饭", "洗碗", "擦地", "洗衣", "呆着" ]
        }, {
            title: "大扫除",
            text: [ "扫地拖地", "卫生间", "擦门窗", "厨房", "阳台", "桌椅", "扫地拖地", "卫生间", "擦门窗", "厨房", "阳台", "桌椅" ]
        }, {
            title: "节假日",
            text: [ "国外游", "国内游", "省内游", "市内游", "梦游", "加班", "国外游", "国内游", "省内游", "市内游", "梦游", "加班" ]
        } ],
        sharing: !1,
        canUserSetVip: !1,
        bnAd_03: t.ad.bnAd_03
    },
    interstitialAdShow: function() {
        a && "function" == typeof a.show && this.canPageShowAd() && a.show().catch(function(t) {
            console.info(t);
        });
    },
    canPageShowAd: function() {
        try {
            var t = wx.getStorageSync("interstitialAdCache-zhuanpan");
            return "" == t || (Date.parse(new Date()) - t.time) / 1e3 > 3600;
        } catch (t) {}
        return !1;
    },
    onLoad: function(e) {
        wx.setStorageSync("zhuanpanlistDefault", this.data.defineText[1].text), wx.createInterstitialAd && this.canPageShowAd() && ((a = wx.createInterstitialAd({
            adUnitId: t.ad.cpAd_03
        })).onLoad(function() {}), a.onError(function(t) {}), a.onClose(function() {
            wx.setStorageSync("interstitialAdCache-zhuanpan", {
                time: Date.parse(new Date())
            });
        }));
    },
    onShow: function() {
        this.setData({
            sharing: !1
        }), "function" == typeof this.getTabBar && this.getTabBar() && this.getTabBar().setData({
            selected: 3
        });
        var t = wx.getStorageSync("zhuanpanlist");
        t ? this.setData({
            defineCurIndex: -1,
            awardsList: t
        }) : this.setData({
            defineCurIndex: 1,
            awardsList: this.data.defineText[1].text
        }), this.initAwardList(this.data.awardsList), this.interstitialAdShow();
    },
    defineTextChange: function(t) {
        var a = t.currentTarget.dataset.index;
        this.setData({
            awardsList: this.data.defineText[a].text,
            defineCurIndex: a
        }), this.initAwardList(this.data.awardsList);
    },
    zdy: function() {
        wx.navigateTo({
            url: "/pages/zp-input/zp-input"
        });
    },
    initAwardList: function(t) {
        for (var a = [], e = 360 / t.length, s = 0; s < t.length; s++) a.push({
            degree: {
                item: "".concat(s * e, "deg"),
                line: "".concat((s + .5) * e, "deg"),
                bg_1: "".concat((s - .5) * e + 90, "deg"),
                bg_2: "".concat(e - 90, "deg")
            },
            award: t[s],
            color: this.getRandomColor(s)
        });
        this.setData({
            awardsList: a
        });
    },
    getLottery: function() {
        this.data.status.voice && (e.stop(), e.startTime = 0, e.play());
        var t = Math.floor(Math.random() * (this.data.awardsList.length - 1 + 1) + 1);
        this.runDegs = this.runDegs || 0, this.runDegs = this.runDegs + (360 - this.runDegs % 360) + (2160 - t * (360 / this.data.awardsList.length)), 
        this.startRun(t, 4e3, this.runDegs);
    },
    voiceChange: function(t) {
        this.setData({
            "status.voice": !this.data.status.voice
        });
    },
    startRun: function(t, a, e) {
        var s = wx.createAnimation({
            duration: a,
            timingFunction: "ease"
        });
        s.rotate(e).step(), this.setData({
            animationData: s.export()
        });
    },
    getRandomColor: function(t) {
        return "#".concat(function t(a) {
            return (a += "0123456789abcdefg"[Math.floor(16 * Math.random())]) && 6 == a.length ? a : t(a);
        }(""));
    },
    styleChange: function() {
        if (1 == this.data.status.style) {
            for (var t = this.data.awardsList, a = 0; a < t.length; a++) t[a].color = this.getRandomColor(a);
            this.setData({
                awardsList: t
            });
        }
        this.setData({
            "status.style": this.data.status.style >= 2 ? 0 : this.data.status.style + 1
        });
    },
    onShareAppMessage: function(t) {
        var a = this.data.defineCurIndex;
        switch (a) {
          case 0:
          case 1:
          case 2:
          case 3:
          case 4:
            this.setData({
                sharing: !0
            });
            this.data.defineText[a].text.join("、");
        }
    }
});